home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Mar 90 / MacApp.Tech$ 3⁄2⁄90 / 0780-ClickCount Bug Fix (-Feb90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.0 KB  |  115 lines  |  [TEXT/GEOL]

  1. Item    3712812                         28-Feb-90        09:23PST
  2.  
  3. From:   MADA2                           MacApp Dev Assoc, Curtis Faith,IVC
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    ClickCount Bug Fix (Long!)
  8.  
  9. I have implemented a workaround fix to the problem of inaccurate gClickCounts.
  10.  
  11. These changes are entirely made in OVERRIDE's.
  12.  
  13. 1) Add the global variable gSavedClickCount.
  14.  
  15. 2) Change HandleMouseDown to save the ClickCount just before calling
  16. CountClicks.  This will enable the TrackMouse method to determine whether the
  17. last mouse press changed gClickCount.  This could be done with a boolean
  18. gClickCountChanged!?, I chose this route.
  19.  
  20. 3) Change the end of TrackMouse to check the pending mouse-up event to see if
  21. this disqualifies the clickCount.  Several notes:
  22.  
  23. a) I made the assumption that there would always be a pending mouse-up event.
  24. I can't see why there would not be, as StillDown must have returned false.
  25.  
  26. b) I removed the special case for movedOnce being FALSE.  This did not allow
  27. one to check the time of the mouse press even if it did not move.
  28.  
  29. c) I should perhaps have done the checking before ConstrainOnce ?
  30.  
  31. These changes appear to fix the problem in all cases that I am able to test,
  32. however, these tests have not been by any means exhaustive.
  33.  
  34. - Curtis
  35.  
  36. VAR
  37.     gSavedClickCount: Integer;
  38.  
  39. {-----------------------------------+}
  40. {| HandleMouseDown |}
  41. {+-----------------------------------}
  42. {$S ARes}
  43. FUNCTION TMyApp.HandleMouseDown (VAR theEventInfo: EventInfo): TCommand;
  44.    OVERRIDE;
  45.  
  46. ( VAR's go here )
  47.  
  48.    BEGIN
  49.    HandleMouseDown := gNoChanges;
  50.  
  51.    WITH theEventInfo, thePEvent^ DO
  52.    BEGIN
  53.    whereMouseDown := FindWindow(where, aWMgrWindow);\
  54.    { +++ Added the following line }
  55.    gSavedClickCount := gClickCount;
  56.    theClickCount := CountClicks(thePEvent, whereMouseDown);
  57.  
  58.    aWindow := WMgrToWindow(aWMgrWindow);
  59.  
  60.     ( Rest of HandleMouseDown goes here )
  61.  
  62.    END;
  63.  
  64. {-----------------------------------+}
  65. {| TrackMouse  |}
  66. {+-----------------------------------}
  67. {$S ARes}
  68. FUNCTION TMyApp.TrackMouse (globalMouse, hysteresis: Point;
  69.    theCommand: TCommand): TCommand;
  70.    OVERRIDE;
  71.  
  72. ( VAR's and local Procedures go here )
  73.  
  74.  
  75.    BEGIN
  76.  ( Setup Stuff goes here )
  77.  
  78.    WHILE StillDown DO
  79.  ( StillDown Stuff goes here )
  80.  
  81.  
  82.    DoFocus;
  83.  
  84.    { +++ Changed the following lines }
  85.    { Notice that I removed the IF NOT movedOnce THEN special case }
  86.  
  87.    IF EventAvail(mUpMask, peekEvent) THEN
  88.    BEGIN
  89.    theQDMouse := peekEvent.where;
  90.    IF view <> NIL THEN
  91.    BEGIN
  92.    GlobalToLocal(theQDMouse);
  93.    view.QDToViewPt(theQDMouse, theMouse);
  94.    END
  95.    ELSE
  96.    PtToVPt(theQDMouse, theMouse);
  97.    ConstrainOnce;
  98.    IF gClickCount > gSavedClickCount THEN
  99.    BEGIN
  100.    IF ((peekEvent.when - gLastUpTime) > GetDblTime) OR (NOT
  101. gTarget.DoMultiClick(gLastMsePt, peekEvent.where)) THEN
  102.    gClickCount := gSavedClickCount;
  103.    END;
  104.    END;
  105.    { +++ End of Changes }
  106.  
  107.    FeedbackOnce(FALSE, TRUE);
  108.    TrackOnce(trackRelease, TRUE);
  109.  
  110.    TrackMouse := tracker;
  111.  
  112.    END;
  113.  
  114.  
  115.